<?php
global $Config;
require_once($Config->WebCMSRoot.'Base/View.php');

Class FotoView extends BaseView
{
	function FotoView()
	{
		parent::BaseView();
	}
	
	function ShowGallery(&$fotos, $page, $pageSize, $fotosPerRow=-1)
	{
		if (count($fotos->Collection) > 0)
		{
		    $this->output = '<div class="fotoRow">';
			$i = 0;
		    
		    foreach ($fotos->Collection as $key=>$foto)
		    {
//print('<pre>'.var_export($foto, true).'</pre>');exit;
			
				if ($key >= (($page-1)*$pageSize) && $key < (($page)*$pageSize))
				{
					$this->output .= '<div class="thumb">';
					$this->output .= "<a href=\"" . $foto->File . "\"";
					$this->output .= " onclick=\"fotoPage(this.href);return false;\">";
					$this->output .= "<img src=\"" . $foto->Thumbnail . "\" border=\"0\" alt=\"\" />";
					$this->output .= '</a></div>';
					
					$i++;
					if ($fotosPerRow > 0 && $i >= $fotosPerRow)
					{
						$this->output .= '</div><div></div>';
						$this->output .= '<div class="fotoRow">';
						$i = 0;
					}
				}
			}

			$this->output .= '</div>';
		}
	}

	function ShowPager(&$fotos, $current, $pageSize, $flag)
	{
		if (count($fotos->Collection) > 0)
		{
			switch ($flag)
			{
				case 'r':
					$page = 'repetities';
					break;
				case 'f':
				default:
					$page = 'fotos';
					break;
			}
		    $this->output = '<div class="fotoRow pager">';
		    
			for ($i=1; $i <= ceil(count($fotos->Collection)/$pageSize); $i++)
			{
				if ($i == $current)
				{
					$this->output .= ' [' . $i . '] ';
				} else {
					$this->output .= ' <a href="/'.$page.'/' . $fotos->Voorstelling->Collection[0]->Jaar . '/' . $i . '">' . $i . '</a> ';
				}
			}
		    
		    $this->output .= '</div>';
		}
	}
}
?>